#include <iostream>
#include <cstring>
#include <cstdio>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cassert>

using namespace std;

int main()
{
    int fd = open("bite", O_RDWR | O_CREAT, 0666);
    assert(fd != -1);
    char str[20] = "i like linux!";
    write(fd, str, strlen(str));
    char buffer[20] = {0};
    ssize_t n = read(fd, buffer, sizeof(buffer)-1);
    buffer[n] = '\0';
    cout <<  buffer << endl;
    close(fd);
    return 0;
}

// int main()
// {
//     int fd = open("bite", O_WRONLY | O_CREAT | O_TRUNC, 0666);
//     assert(fd != -1);
//     char str[20] = "i like linux!";
//     write(fd, str, strlen(str));
//     close(fd);
//     fd = open("bite", O_RDONLY);
//     char outputstr[20];
//     ssize_t n = read(fd, outputstr, 20);
//     outputstr[n] = '\0';
//     cout << outputstr << endl;
//     close(fd);
//     return 0;
// }